<script lang="ts" setup>
import type { VbenFormProps } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import type { ScrapModel } from '#/api/quality/models';

import { Page } from '@vben/common-ui';

import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { getScrapPagedListApi } from '#/api/quality/scrap';

import { useColumns, useSearchSchema } from './data';

const formOptions: VbenFormProps = {
  collapsed: true,
  schema: useSearchSchema(),
  // 控制表单是否显示折叠按钮
  showCollapseButton: true,
  submitOnEnter: true,
};

const gridOptions: VxeGridProps<ScrapModel> = {
  columns: useColumns(),
  border: true,
  stripe: true,
  pagerConfig: {},
  proxyConfig: {
    ajax: {
      query: async ({ page }, formValues) => {
        return await getScrapPagedListApi({
          pageNumber: page.currentPage,
          pageSize: page.pageSize,
          ...formValues,
        });
      },
    },
  },
};

const [Grid] = useVbenVxeGrid({ gridOptions, formOptions });
</script>

<template>
  <Page auto-content-height>
    <Grid />
  </Page>
</template>
